class NextName {
  constructor() {
    this.nextId  = 0;
    this.map = {};
  }
  getName(name) {
    let nextId = this.map[name];
    if (!nextId) {
      nextId = this.map[name] = this.getNextId();
    }
    return nextId;
  }
  getNextId() {
    let id = this.nextId;
    let turn = Math.floor(id / 26);
    id = id % 26;
    this.nextId++;
    const name = String.fromCharCode(97 + id) + (turn ? turn : '');
    return name;
  }
}

export default NextName;
